/**
 * Bob.Ren
 * 2013-7-5
 */
package com.noqueue.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.noqueue.dao.CustomerQueueDao;
import com.noqueue.entity.CustomerQueue;

/**
 * @author Bob.Ren
 * @date 2013-7-5
 */
@Repository
public class CustomerQueueDaoImpl extends BaseDaoImpl<CustomerQueue, String>
		implements CustomerQueueDao {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.noqueue.dao.CustomerQueueDao#loadByEateryIdAndCusstomerId(java.lang
	 * .String, java.lang.String)
	 */
	@Override
	@SuppressWarnings("unchecked")
	public CustomerQueue loadByEateryIdAndCusstomerId(String eateryId,
			String customerId) {
		String sql = "from CustomerQueue customerQueue where customerQueue.eateryId = ? and customerQueue.customer.id > ?";

		List<CustomerQueue> list = getSession().createQuery(sql)
				.setParameter(0, eateryId).setParameter(1, customerId).list();

		return list.size() > 0 ? list.get(0) : null;

	}
}
